package client;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.*;

public class SwingClient {
	
	public SwingClient() {}
	
	public void build() {
		JFrame frame = new JFrame();
		Container content = frame.getContentPane();
		buildMenu(frame);
		content.setLayout(new BorderLayout());
		buildButtonPanel(content);
		
		frame.pack();
		frame.setVisible(true);
	}

	private void buildMenu(JFrame frame) {
		JMenuBar menuBar = new JMenuBar();
		JMenu menu = new JMenu("File");
		JMenuItem file = new JMenuItem("Quit");
		// TODO Add event listeners to menu items
		menu.add(file);
		frame.setJMenuBar(menuBar);
	}

	private void buildButtonPanel(Container c) {
		JPanel surround = new JPanel();
		surround.setBorder(new EmptyBorder(20,20,20,20));
		for (final SettingsPanels panel : SettingsPanels.values()) {
			JButton button = new JButton(panel.getButtonLabel());
			button.addActionListener(new ActionListener () {
				@Override public void actionPerformed(ActionEvent arg0) {
					showSettingsPanel(panel.getPanel());
				}
			});
			surround.add(button);
		}
		c.add(surround,BorderLayout.CENTER);
	}

	private void showSettingsPanel(JPanel panel) {
		// TODO Make button click display the settings panel
		
	}
}
